<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
	<meta http-equiv="X-UA-Compatible" content="IE=edge" />
	<title>乐鲜生活-登录</title>
	<link rel="shortcut icon" href="favicon.ico" />
	<link rel="bookmark" href="favicon.ico" />
	<link rel="stylesheet" type="text/css" href="css/base.css" />
	<link rel="stylesheet" type="text/css" href="css/asyncbox/asyncbox.css" />
	<link rel="stylesheet" type="text/css" href="css/login.css" />
</head>
<body>
	<div id="wrapper">
		<div class="nav" style="border-bottom: none">
			<div class="main_nav" style="height: 90px; line-height: 90px; margin-top: 25px; padding-left: 160px">
				<div class="nav_left">
					<a href="index.html"><img src="icons/logo.png" width="80" /></a><span>欢迎登录</span>
				</div>
				<div class="clr"></div>
			</div>
		</div>

		<div class="main">
			<div class="clear">
				<div class="left"></div>
				<div class="right">
					<div class="loginBox">
						<div class="boxWrap">
							<div class="titleL">
								<span>登录</span>
								<a href="register.html">免费注册</a>
							</div>
							<div class="th">账户</div>
							<div>
								<input type="text" id="username" placeholder="请输入用户名" autofocus />
							</div>
							<div class="th" style="margin-top: 15px">
								<span>密码</span>
								<a href="forgetthepassword.html" tabIndex="-1">忘记密码</a>
							</div>
							<div>
								<input type="password" id="password" placeholder="请输入密码" />
							</div>
							<div class="lg">
								<a id="submit">登录</a>
							</div>
							<!--<div class="hz">乐鲜生活信用</div>-->
							<ul class="other clear">
								<li class="icon1"><a href="javascript:void(0)">正品保障</a></li>
								<li class="icon2"><a href="javascript:void(0)">公平公正</a></li>
								<li class="icon3"><a href="javascript:void(0)">安全服务</a></li>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="footer" id="footer"></div>
	</div>
	<script type="text/javascript" src="js/site/jquery-1.8.2.min.js"></script>
	<script type="text/javascript" src="js/site/AsyncBox.v1.4.js"></script>
	<script type="text/javascript" src="js/site/validate.js"></script>
	<script type="text/javascript" src="js/site/String.js"></script>
	<script type="text/javascript" src="js/site/common.js"></script>
	<script type="text/javascript">
		$(function() {
			$("#username").focus();
			
			$("#submit").click(function() {
				submit();
			});
			$("#password").enter(submit);
		});
	
		function submit() {
			var username = $.trim($("#username").val());
			var password = $.trim($("#password").val());
			if (!validateUtil.validateEmpty(username)) {
				asyncbox.tips("请输入账户名！", asyncbox.Level.error);
				return;
			}
			if (!validateUtil.validatePhone(username)) {
				asyncbox.tips("用户名格式错误！", asyncbox.Level.error);
				return;
			}
			if (!validateUtil.validateLength(username, 11, 11)) {
				asyncbox.tips("请输入正确的账户名！", asyncbox.Level.error);
				return;
			}
			if (!validateUtil.validateEmpty(password)) {
				asyncbox.tips("请输入密码！", asyncbox.Level.error);
				return;
			}
	
			var data = {
				phone : username,
				passwd : password
			};
			$.postAjax("/user/remLogin.do", data, function(json) {
				if (json.code) {
					asyncbox.tips(json.message, asyncbox.Level.error);
					return;
				}
				if (json.code == 99) {
					asyncbox.tips(json.message, asyncbox.Level.error);
					return;
				}
				window.location = 'index.html';
			}, function() {
				asyncbox.tips("网络连接错误", asyncbox.Level.error);
			});
		}
	</script>
</body>
</html>